<!-- 测试底部导航栏 -->
<template>
  <div>
    <!-- 底部导航栏 -->
    <!-- 图片动态更新有两种方法，其中优雅方式为require(),另一种为v-if方法实现 -->
    <!-- vant 自定义图标写法 -->
    <van-tabbar v-model="active">
      <van-tabbar-item id="share">
        <span>分享</span>
        <template #icon="props">
          <img :src="props.active ? icon.active1 : icon.inactive1" />
        </template>
      </van-tabbar-item>

      <van-tabbar-item id="help">
        <span>求助</span>
        <template #icon="props">
          <img :src="props.active ? icon.active2 : icon.inactive2" />
        </template>
      </van-tabbar-item>

      <van-tabbar-item id="home">
        <span>首页</span>
        <template #icon="props">
          <img :src="props.active ? icon.active3 : icon.inactive3" />
        </template>
      </van-tabbar-item>

      <van-tabbar-item id="news">
        <span>消息</span>
        <template #icon="props">
          <img :src="props.active ? icon.active4 : icon.inactive4" />
        </template>
      </van-tabbar-item>

      <van-tabbar-item id="my">
        <span>我的</span>
        <template #icon="props">
          <img :src="props.active ? icon.active5 : icon.inactive5" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  data() {
    return {
      active: 0,
      icon: {
        // 每一个图标都绑定点击和不点击的区别，写成这样因为我写成一条代码写不对
        active1: require(`../assets/tabbar/sharecolor.png`),
        inactive1: require(`../assets/tabbar/share.png`),
        active2: require(`../assets/tabbar/helpcolor.png`),
        inactive2: require(`../assets/tabbar/help.png`),
        active3: require(`../assets/tabbar/home.png`),
        inactive3: require(`../assets/tabbar/home.png`),
        active4: require(`../assets/tabbar/newscolor.png`),
        inactive4: require(`../assets/tabbar/news.png`),
        active5: require(`../assets/tabbar/mycolor.png`),
        inactive5: require(`../assets/tabbar/my.png`),
      },
    };
  },
};
</script>

<style>
</style>